#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define ll long long
#define fi first
#define se second
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define getBit(mask, k) (((mask) / pw[k]) % pw[1])
#define setBit(mask, k, l) (((mask) / pw[k + 1] * pw[1] + (l)) * pw[k] + ((mask) % pw[k]))
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define ff first
#define ss second 
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const int inf = 1 << 28;
const ldb pi = fabsl(atan2l(0.0, -1.0));
using namespace std;

int n, m;
char s[1000110], t[1000110];
const ll X = 239;
ll hl[2][1000110];
ll hr[2][1000110];
ll pw[1000010];
int p[1000010], q[1000010];
int up[1000002][21];

void load()
{
	gets(s);
	gets(t);
	n = strlen(s);
	for (int i = 0; i <= n; i++)
	{
		if (i)
			pw[i] = pw[i - 1] * X;
		else
			pw[i] = 1;
	}
}

void countHash(char *s, ll *hl)
{
	for (int i = 0; i < n; i++)
	{
		if (i)
			hl[i] = hl[i - 1] * X + s[i];
		else
			hl[i] = s[i];
	}
}

int findLength(char *s, char *t, int i, ll *hr0, ll *hl1)
{
	int l = 1;
	int r = n - i - 2;
	int mid, res = 0;
	while (l <= r)
	{
		mid = (l + r) / 2;
		if (hr0[i + 1] - hr0[i + 1 + mid] * pw[mid] == hl1[n - 1] - hl1[n - 1 - mid] * pw[mid])
		{
			res = mid;
			l = mid + 1;
		}
		else r = mid - 1;
	}
	return res;
}

void solve()
{
	n = strlen(s);
	m = strlen(t);
	if (n != m)
	{
		cout << -1 << " " << -1;
		return;
	}
	reverse(t, t + n);
	for (int i = 0; i < n; i++)
	{
		if (i)
		{
			hl[0][i] = hl[0][i - 1] * X + s[i];
			hl[1][i] = hl[1][i - 1] * X + t[i];
		}
		else
		{
			hl[0][i] = s[i];
			hl[1][i] = t[i];
		}
	}
	for (int i = n - 1; i >= 0; i--)
	{
		if (i < n - 1)
			hr[0][i] = hr[0][i + 1] * X + s[i];
		else
			hr[0][i] = s[i];
	}


	q[1] = 0;
	for (int i = 2, k = 0; i <= n; i++)
	{
		while (k > 0 && s[n - 1 - (i - 1)] != s[n - 1 - (k)]) k = q[k];
		if (s[n - 1 - (i - 1)] == s[n - 1 - (k)]) k++;
		q[i] = k;
	}

	for (int i = n - 1, k = 0; i >= 0; i--)
	{
		while (k > 0 && s[n - 1 - k] != t[i]) k = q[k];
		if (s[n - 1 - k] == t[i]) k++;
		p[i] = k;
	}


	int ri = -1, rj = -1;
	for (int i = 0; i + 1 < n && s[i] == t[i]; i++)
	{
		int l1 = findLength(s, t, i, hr[0], hl[1]);
		int l2 = p[i + 1];
		if (l1 + l2 >= n - i - 1)
		{
			int j = l2;
			ri = i;
			rj = i + (n - i - 1 - l2) + 1;
		}
	}
	cout << ri << " " << rj;
}

#define file "d"
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file".out", "wt", stdout);
	#endif
	load();
	solve();
	return 0;
}
